package com.packenius.library.xspdf;

/**
 * Destination that marks a line on a page.
 * @author Christian Packenius, 2013.
 */
class XSLineDestination implements XSDestination {
  /**
   * Number of page to be marked (>= 0).
   */
  final int pageID;

  /**
   * Line on the page (from top of the page).
   */
  final double lineY;

  /**
   * Constructor.
   * @param pageID Page ID, starting with 0.
   * @param lineY Line on the page (from top of the page).
   */
  XSLineDestination(int pageID, double lineY) {
    this.pageID = pageID;
    this.lineY = lineY;
  }

  /**
   * @see com.packenius.library.xspdf.XSPdfContent#getPdfContent(com.packenius.library.xspdf.XSPDF)
   */
  public String getPdfContent(XSPDF xsPDF) {
    XSPage page = xsPDF.pages.get(pageID);
    int pageObjectID = page.pdfObjectID;
    return "/Dest[" + pageObjectID + " 0 R/XYZ null " + lineY + " 0]>>";
  }
}
